4 # IMPORTANT: Use the following statement at the TOP OF EVERY TEST SCRIPT
5 # to ensure that this package's 'bin/' subfolder is added to the path so that
6 # this package's CLIs can be invoked by their mere filename in the rest
9 PATH
=${PWD%%/test*}/bin
:$PATH
11 # Make the unreadable file readable again on exit, to avoid problems with Git not being able to read it either.
12 trap 'chmod +r "./Data/Unreadable.pm"' EXIT
14 # Helper function for error reporting.
15 die
() { (( $# > 0 )) && echo "ERROR: $*" >&2; exit 1; }
17 # Note that only -v results in trying to read the module file,
18 # and that even an inability to load the file is not considered a fatal
19 # error - it merely triggers a warning.
21 # -- Test with a file that we don't have read permissions for.
22 chmod -r './Data/Unreadable.pm' || die
"Failed to set permissions."
23 errOut
=$
(whichpm
-v Data
::Unreadable
2>&1 1>/dev
/null
) || die
24 [[ $errOut =~
'Failed to load' ]] || die
"Expected warning about failure to load unreadable file, got '$errOut'."
26 # -- Test with a file that doesn't contain valid Perl source code.
27 errOut
=$
(whichpm
-v Data
::Invalid
2>&1 1>/dev
/null
) || die
28 [[ $errOut =~
'Failed to load' ]] || die
"Expected warning about failure to load invalid file, got '$errOut'."